﻿@model Zatify.WebUI.Areas.Admin.Models.Reports.UserReferrerReportViewModel
@{
    ViewBag.Title = "User Referrer Report";
    Layout = "~/Areas/Admin/Views/Shared/_AdminReportsLayout.cshtml";
}
@section Styles
{
    <style type="text/css">
        table.tableFilters
        {
            border: 0px solid #C0B5A3;
        }
        table.tableFilters tr td
        {
            border: 0;
        }
        table.tableFilters .apps_btn
        {
            margin: 5px 0 0;
        }
        .report_filter_area
        {
            min-height: auto;
        }
        .filtersForm
        {
            background-color: #D3DFE6;
            border: 1px solid #C0B5A3;
        }
    </style>
}
@section Scripts
{
    <script src="@Url.Content("~/Scripts/jquery-ui-1.9.2.min.js")" type="text/javascript"></script>
    <script type="text/javascript">

        $(document).ready(function () {

            $('#DateFrom').datepicker({
                minDate: new Date(2013, 1 - 1, 1),
                maxDate: "+40y",
                changeMonth: true,
                changeYear: true,
                showButtonPanel: false,
                dateFormat: 'dd MM yy'
            });

            $('#DateTo').datepicker({
                minDate: new Date(2013, 1 - 1, 1),
                maxDate: "+40y",
                changeMonth: true,
                changeYear: true,
                showButtonPanel: false,
                dateFormat: 'dd MM yy'
            });

            $("#expanderHead").click(function () {
                $("#userReferrersFiltersForm").slideToggle();
                if ($("#expanderSign").text() == "+ Show Filters") {
                    $("#expanderSign").html("- Hide Filters")
                }
                else {
                    $("#expanderSign").text("+ Show Filters")
                }
            });
        });

        function postUserReferrersFiltersForm() {

            $("#page").val($("#pageNum").val());
            $("#userReferrersFiltersForm").submit();
        }

        function filterUserReferrersForm() {

            $("#page").val(1);
            $("#userReferrersFiltersForm").submit();
        }
    
    </script>
}
<table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td valign="top" bgcolor="#ECECEC">
            <div class="report_filter_area">
                <h6 id="expanderHead" style="text-align: left; cursor: pointer; margin: 10px 0;">
                    <span id="expanderSign">- Hide Filters</span></h6>
                @*<p>*@
                @using (Html.BeginForm("UserReferrers", "Reports", FormMethod.Post, new { id = "userReferrersFiltersForm", @class = "filtersForm" }))
                {
                    @Html.Hidden("page", 1)
                        
                    <table class="tableFilters">
                        <tr>
                            <td colspan="4">
                                @*<h5 id="expanderHead" style="margin-bottom: 10px; cursor: pointer;">
                                    Report Filters</h5>*@
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <strong>From:</strong>
                            </td>
                            <td>
                                @Html.TextBox("DateFrom", (Model.DateFrom.HasValue ? Model.DateFrom.Value.ToString("dd MMMM yyyy") : String.Empty), new { @class = "apps_inputbox" })
                            </td>
                            <td>
                                <strong>To:</strong>
                            </td>
                            <td>
                                @Html.TextBox("DateTo", (Model.DateTo.HasValue ? Model.DateTo.Value.ToString("dd MMMM yyyy") : String.Empty), new { @class = "apps_inputbox" })
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <strong>Referred by ID:</strong>
                            </td>
                            <td>
                                @Html.TextBoxFor(m => m.ReferredByID, new { @class = "apps_inputbox" })
                            </td>
                            <td>
                                <strong>Referred ID:</strong>
                            </td>
                            <td>
                                @Html.TextBoxFor(m => m.ReferredID, new { @class = "apps_inputbox" })
                            </td>
                        </tr>
                        <tr>
                            <td colspan="4">
                                <input type="submit" class="btn apps_btn apps_gray_btn" value="Search" onclick="filterUserReferrersForm();" />
                            </td>
                        </tr>
                    </table>
                }
                @*</p>*@
            </div>
        </td>
    </tr>
    <tr>
        <td valign="top">
            <div class="report_result_area">
                <h5>
                    User Referrer Report</h5>
            </div>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <th width="13%">
                        <a href="@Url.Action("UserReferrers", new { sortOrder = Model.IDSortParam, dateFrom = Model.DateFrom, dateTo = Model.DateTo, referredByID = Model.ReferredByID, referredID = Model.ReferredID, page = Model.PagingInfo.CurrentPage })">
                            ID</a>
                    </th>
                    <th width="16%">
                        <a href="@Url.Action("UserReferrers", new { sortOrder = Model.ReferredByIDSortParam, dateFrom = Model.DateFrom, dateTo = Model.DateTo, referredByID = Model.ReferredByID, referredID = Model.ReferredID, page = Model.PagingInfo.CurrentPage })">
                            Referred by ID</a>
                    </th>
                    <th width="16%">
                        <a href="@Url.Action("UserReferrers", new { sortOrder = Model.ReferredIDSortParam, dateFrom = Model.DateFrom, dateTo = Model.DateTo, referredByID = Model.ReferredByID, referredID = Model.ReferredID, page = Model.PagingInfo.CurrentPage })">
                            Referred ID</a>
                    </th>
                    <th width="16%">
                        <a href="@Url.Action("UserReferrers", new { sortOrder = Model.ReferredIDUserTypeSortParam, dateFrom = Model.DateFrom, dateTo = Model.DateTo, referredByID = Model.ReferredByID, referredID = Model.ReferredID, page = Model.PagingInfo.CurrentPage })">
                            Referred ID UserType</a>
                    </th>
                    <th width="16%">
                        <a href="@Url.Action("UserReferrers", new { sortOrder = Model.DateSortParam, dateFrom = Model.DateFrom, dateTo = Model.DateTo, referredByID = Model.ReferredByID, referredID = Model.ReferredID, page = Model.PagingInfo.CurrentPage })">
                            Date</a>
                    </th>
                    <th width="13%">
                        <a href="@Url.Action("UserReferrers", new { sortOrder = Model.NoSortParam, dateFrom = Model.DateFrom, dateTo = Model.DateTo, referredByID = Model.ReferredByID, referredID = Model.ReferredID, page = Model.PagingInfo.CurrentPage })">
                            No</a>
                    </th>
                    <th width="13%">
                        <a href="@Url.Action("UserReferrers", new { sortOrder = Model.TotalSortParam, dateFrom = Model.DateFrom, dateTo = Model.DateTo, referredByID = Model.ReferredByID, referredID = Model.ReferredID, page = Model.PagingInfo.CurrentPage })">
                            Total</a>
                    </th>
                </tr>
                @foreach (var userReferrer in Model.UserReferrers)
                {
                    <tr>
                        <td style="text-align: right;">
                            @userReferrer.ID
                        </td>
                        <td>
                            @userReferrer.Referred_by_ID
                        </td>
                        <td>
                            @userReferrer.Referred_ID
                        </td>
                        <td>
                            @userReferrer.Referred_ID_UserType
                        </td>
                        <td style="text-align: right;">
                            @userReferrer.Date
                        </td>
                        <td style="text-align: right;">
                            @userReferrer.No
                        </td>
                        <td style="text-align: right;">
                            @userReferrer.Total
                        </td>
                    </tr>
                }
            </table>
            <!--start pagination-->
            <div class="zatify_pagination">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        @Html.PageLinks(Model.PagingInfo, x => Url.Action("UserReferrers", new
                   {
                       page = x,
                       sortOrder = Model.SortOrderParam,
                       dateFrom = (Model.DateFrom.HasValue ? Model.DateFrom.Value.ToString("dd MMMM yyyy") : null),
                       dateTo = (Model.DateTo.HasValue ? Model.DateTo.Value.ToString("dd MMMM yyyy") : null),
                       referredByID = Model.ReferredByID,
                       referredID = Model.ReferredID
                   }),
                           Url.Content("~/Areas/Admin/Content/zatify/Images/page_first_btn.png"),
                           Url.Content("~/Areas/Admin/Content/zatify/Images/page_last_btn.png"),
                           Url.Content("~/Areas/Admin/Content/zatify/Images/page_back.png"),
                           Url.Content("~/Areas/Admin/Content/zatify/Images/page_next.png"))
                        <td width="6%">
                            Page No:
                        </td>
                        <td width="11%">
                            @Html.DropDownList("pageNum", (IEnumerable<SelectListItem>)ViewData["pagesCount"], new { onchange = "postUserReferrersFiltersForm();", @class = "select_box" })
                        </td>
                        <td width="2%">
                            <img src="@Url.Content("~/Areas/Admin/Content/zatify/Images/excel_icon.png")" alt="" title="back" border="0" />
                        </td>
                        <td class="pagination_no" width="15%">
                            <a href="@Url.Action("UserReferrersReport", "Reports", new { dateFrom = Model.DateFrom, dateTo = Model.DateTo, referredByID = Model.ReferredByID, referredID = Model.ReferredID, reportExportType = Zatify.WebUI.Areas.Admin.Models.Reports.ReportExportType.Excel })">
                                Export to Excel</a>
                        </td>
                        <td width="2%">
                            <img src="@Url.Content("~/Areas/Admin/Content/zatify/Images/pdf_icon.png")" alt="" title="back" border="0" />
                        </td>
                        <td class="pagination_no" width="15%">
                            <a href="@Url.Action("UserReferrersReport", "Reports", new { dateFrom = Model.DateFrom, dateTo = Model.DateTo, referredByID = Model.ReferredByID, referredID = Model.ReferredID, reportExportType = Zatify.WebUI.Areas.Admin.Models.Reports.ReportExportType.PDF })">
                                Export to PDF</a>
                        </td>
                        <td width="2%">
                            <img src="@Url.Content("~/Areas/Admin/Content/zatify/Images/printing_icon.gif")" alt="" title="back" border="0" />
                        </td>
                        <td class="pagination_no" width="15%">
                            <a href="@Url.Action("UserReferrersReport", "Reports", new { dateFrom = Model.DateFrom, dateTo = Model.DateTo, referredByID = Model.ReferredByID, referredID = Model.ReferredID, reportExportType = Zatify.WebUI.Areas.Admin.Models.Reports.ReportExportType.Print })">
                                Printing</a>
                        </td>
                        <td width="15%">
                            <span class="page_no_info">@Model.PagingInfo.TotalItems items in @Model.PagingInfo.TotalPages
                                pages</span>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="clearfix">
            </div>
            <!--end pagination-->
        </td>
    </tr>
</table>
